package com.my.screenadapter.sql;

import android.util.Log;
import android.widget.Toast;

import com.google.gson.Gson;
import com.my.screenadapter.Base.BaseActivity;
import com.my.screenadapter.MyApplication;
import com.my.screenadapter.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import butterknife.OnClick;

/**
 * Created by 张英杰 on 2017/4/7.
 */

public class SqlTestActivity extends BaseActivity {
    @Override
    protected void init() {

    }

    @Override
    protected int initLayoutId() {
        return R.layout.activity_sqltest;
    }

    @OnClick(R.id.btn1)
    public void addNews(){
        News news = new News();
//        Introduction introduction = new Introduction();
//        introduction.setGuide("介绍  setGuide 1");
//        introduction.setDigest("介绍 Digest 1");
//        news.setIntroduction(introduction);

        news.setNewsid(new Random(20)+"  new s内容");
        boolean save = news.save();
        List<Comment> commentList =new ArrayList<>();
        Comment comment = new Comment();
        comment.setCommentContent( new Random(20)+"  ss内容");
        comment.setNews(news);
        boolean save1 = comment.save();
        commentList.add(comment);
        Comment comment2 = new Comment();
        comment2.setCommentContent( new Random(20)+"  2ss内容");
        comment2.setNews(news);
        commentList.add(comment2);
        boolean save2 = comment2.save();
//        news.setCommentList(commentList);

        Gson gson = new Gson();
        Toast.makeText(this,save+ "   "+save1+"  "+save2,Toast.LENGTH_LONG).show();
        Toast.makeText(this,news.toString(),Toast.LENGTH_LONG).show();
        Log.i("save===", "addNews: "+save+ "   "+news.toString());
        Log.i("save===", save1+" "+save2);

//        Log.i("list===", news.getCommentList().get(0).toString());
//        for (int i = 0; i < news.getCommentList().size(); i++) {
//
//        }
    }
}
